﻿// <copyright file="CharactersGM.cs" company="Gravity Age Studios">
// Code released under the MIT license (see License.txt).
// </copyright>
// <author>Vicente Cartas Espinel</author>
// <email>vicente.cartas@gmail.com</email>
namespace LightSwitchApplication
{
    using System;
    using System.Windows.Controls;
    using Microsoft.LightSwitch.Presentation;
    using Microsoft.LightSwitch.Presentation.Extensions;
    using LightSwitchApplication.Import;
    using LightSwitchApplication.Export;

    public partial class CharactersGM
    {
        #region Add/Edit Character

        partial void gridAddAndEditNew_Execute()
        {
            this.Application.ShowCharacterAddEditGM(null);
        }

        partial void gridEditSelected_CanExecute(ref bool result)
        {
            result = this.Collection.SelectedItem != null;
        }

        partial void gridEditSelected_Execute()
        {
            this.Application.ShowCharacterAddEditGM(this.Collection.SelectedItem.Id);
        }

        #endregion

        partial void Import_Execute()
        {
            ImporterHelper.ImportCharacters(this.DataWorkspace, this.Collection);
        }

        partial void Export_Execute()
        {
            Exporter.ExportCharacters(this.Collection);
        }
    }
}
